package com.design.pattern.singleton;

public class LockBolckSingleton {
    /**
     * 构造方法私有化,防止直接new实例.
     */
    private LockBolckSingleton() {
    }

    /**
     * 持有本类
     */
    private static LockBolckSingleton instance;

    /**
     * 对外暴露的方法,返回单例实例(方法加锁)
     *
     * @return 单例实例
     */
    public synchronized static LockBolckSingleton getInstance() {
        if (null == instance) {
            synchronized (LockBolckSingleton.class) {
                instance = new LockBolckSingleton();
            }
        }
        return instance;
    }
}
